<template>
	<view class="page">
	  <view class="height20"></view>
	  <!-- 订单信息 -->
	  <view class="car-info">
	    <view class="carName" v-if="orderList.brand">{{orderList.brand + "　" + orderList.series + "　" + orderList.vehicle_type}}</view>
	    <view class="list">
	      <view class="item">
	        <view class="left">
	          <text class="letter-spacing">订单</text>号
	        </view>
	        <view class="right">{{orderList.order_no}}</view>
	      </view>
	      <view class="item">
	        <view class="left"><text class="letter-spacing">成交</text>价</view>
	        <view class="right">{{(orderList.transaction_price * 1).toFixed(2)}}元</view>
	      </view>
	      <view class="item">
	        <view class="left">首付方式</view>
	        <view class="right">{{orderList.down_method}}</view>
	      </view>
	      <view class="item" v-if="orderList.down_method == '按比例支付'">
	        <view class="left">首付比例</view>
	        <view class="right">{{orderList.down_ratio}}%</view>
	      </view>
	      <view class="item" v-if="orderList.down_method == '按定额支付'">
	        <view class="left">首付金额</view>
	        <view class="right">{{(orderList.down_amount * 1).toFixed(2)}}</view>
	      </view>
	      <view class="item">
	        <view class="left">贷款期数</view>
	        <view class="right">{{orderList.periods}}期</view>
	      </view>
	      <view class="item" v-if="orderList.biz_type == 7">
	        <view class="left">是否贴息</view>
	        <view class="right">{{orderList.discount_status}}</view>
	      </view>
	      <view class="item" v-if="orderList.discount_status == '是'">
	        <view class="left">贴息方案</view>
	        <view class="right">{{orderList.discount_name}}</view>
	      </view>
	      <view class="item">
	        <view class="left">还款方式</view>
	        <view class="right">{{orderList.repayment}}</view>
	      </view>
	      <view class="item">
	        <view class="left">借款金额</view>
	        <view class="right">{{(orderList.loan_amount*1).toFixed(2)}}元</view>
	      </view>
	    </view>
	  </view>
	  <view class="height20"></view>
	  <!-- 个人信息 -->
	  <view class="personal-information">
	    <view class="item">
	      <view class="left">姓　　名</view>
	      <view class="right">{{orderList.user_name}}</view>
	    </view>
	    <view class="item">
	      <view class="left"><text class="letter-spacing">手机</text>号</view>
	      <view class="right">{{orderList.user_mobile}}</view>
	    </view>
	  </view>
	  <!-- 审核结果 -->
	  <view class="order-status">
	    <view class="item order-item">
	      <view class="left">审核结果</view>
	      <view class="right green">{{orderList.statusName}}</view>
	    </view>
	    <view class="item" v-if="orderList.statusName == '已放款'">
	      <view class="left">账　　单</view>
	      <view class="right green" @click="viewBill">查看账单</view>
	    </view>
	  </view>
	  <view class="border1px"></view>
	  <view class="height20"></view>
	  <!-- 未完成订单继续操作 -->
	  <view class="btnBox" v-if="orderList.statusName == '未完成'">
	    <button size="default" class="btn leftBtn" type="primary" @click="navigateBack">返回</button>
	    <button size="default" class="btn rightBtn" type="primary" @click="toInformation">完成订单</button>
	  </view>
	  <!-- 待初审/待复审/审核拒绝状态 -->
	  <view class="btnBox" v-else>
	    <button size="default" class="btn" type="primary" @click="navigateBack">返回</button>
	  </view>
	</view>
</template>

<script>
	import {getOrderDetailsByOrderId} from '@/service/chengyongche'
	export default {
		data() {
			return {
				orderList: {},
				userInfoData: {},
				userInfoData: {},
				header: ''
			}
		},
		onLoad() {
			let _this=this,
				orderId = uni.getStorageSync('orderDate').orderId,
				userInfoData = uni.getStorageSync('userInfo'),
				header = {
					'content-type': 'application/x-www-form-urlencoded',
					'Authorization': userInfoData.token
				};
			_this.userInfoData = userInfoData
			_this.orderId = orderId
			_this.header = header
			let prams = {orderId}
			this._getOrderDetailsByOrderId(prams, header)
		},
		methods: {
			navigateBack() {
				uni.navigateBack();
			},
			/**
			 * 查看账单触发
			 * @method viewBill
			 */
			viewBill() {
				uni.navigateTo({url: '/pages/chengyongche/bill/bill'});
			},
			/**
			 * 点击完成订单触发
			 * @method toInformation
			 */
			toInformation() {
				let orderId = this.orderId
				uni.navigateTo({ url: '/pages/chengyongche/personal-information/personal-information?orderId='+orderId });
			},
			// -----------------------网络请求--------------------------
			_getOrderDetailsByOrderId(prams, header) {
				uni.showLoading();
				let _this = this;
				getOrderDetailsByOrderId(JSON.stringify(prams), header).then(res => {
					console.log(res);
					let data = res.data;
					uni.hideLoading();
					if(data.resultCode != "0000") {
						uni.showModal({
							showCancel: false,
							content: data.resultMsg,
							success: () => {
								uni.hideLoading();
							}
						})
					}else {
						this.orderList = data.data.orderDetails;
					}
				}).catch(err => {
					console.log(err);
					uni.hideLoading();
				})
			},
		}
	}
</script>

<style>
	@import url("./orderDetail.css");
</style>
